package pl.prv.polanie.client.panels;

import pl.prv.polanie.client.Planner;
import pl.prv.polanie.client.panels.lists.AcademicTitlesList;
import pl.prv.polanie.client.panels.lists.BuildingsList;
import pl.prv.polanie.client.panels.lists.CalendarDaysList;
import pl.prv.polanie.client.panels.lists.GroupsList;
import pl.prv.polanie.client.panels.lists.LecturersList;
import pl.prv.polanie.client.panels.lists.PreferenceTypesList;
import pl.prv.polanie.client.panels.lists.RoomTypesList;
import pl.prv.polanie.client.panels.lists.RoomsList;
import pl.prv.polanie.client.panels.lists.SemestersYearGroupsList;
import pl.prv.polanie.client.panels.lists.SubgroupTypesList;
import pl.prv.polanie.client.panels.lists.SubjectNamesList;
import pl.prv.polanie.client.panels.lists.SubjectTypesList;
import pl.prv.polanie.client.panels.lists.SubjectsList;
import pl.prv.polanie.client.panels.lists.YearGroupNamesList;
import pl.prv.polanie.client.panels.tabpanel.MinimizableSimplePanel;
import pl.prv.polanie.client.panels.widgets.HTMLLink;

import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class DatabaseVP extends VerticalPanel {
	
	HTMLLink listAcademicTitlesHTMLLink = new HTMLLink("Academic Titles"); 
	HTMLLink listLecturersHTMLLink = new HTMLLink("Lecturers");
	HTMLLink listBuildingsHTMLLink = new HTMLLink("Buildings");
	HTMLLink listPreferenceTypesHTMLLink = new HTMLLink("Preference Types");
	HTMLLink listRoomTypesHTMLLink = new HTMLLink("Room Types");
	HTMLLink listRoomsHTMLLink = new HTMLLink("Rooms");
	HTMLLink listSubjectTypesHTMLLink = new HTMLLink("Subject Types");
	HTMLLink listSubjectNamesHTMLLink = new HTMLLink("Subject Names");
	HTMLLink listSubjectsHTMLLink = new HTMLLink("Subjects");

	
	HTMLLink listSubgroupTypesHTMLLink = new HTMLLink("Subgroup types");
//	HTMLLink listStudiesTypesHTMLLink = new HTMLLink("Studies Types");
//	HTMLLink listSemesterTypesHTMLLink = new HTMLLink("Semester Types");
	HTMLLink listSemestersHTMLLink = new HTMLLink("Semesters");
	HTMLLink listCalendarDaysHTMLLink = new HTMLLink("Calendar Days");
	
	HTMLLink listYearGroupNamesHTMLLink = new HTMLLink("Year Group Names");
	HTMLLink listSemestersYearGroupsHTMLLink = new HTMLLink("Semester Year Groups");
	HTMLLink listGroupsHTMLLink = new HTMLLink("Groups");
//	HTMLLink listSubgroupsHTMLLink = new HTMLLink("Subgroups");
	
//	HTMLLink listSubjectEventsHTMLLink = new HTMLLink("Subject Events");
	

	
	public DatabaseVP() {

		add(listAcademicTitlesHTMLLink);
		listAcademicTitlesHTMLLink.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
				String tabLabel = "Academic titles";
				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "ACADEMIC_TITLES");
				
				//sciagamy dane do nowootwartej zakladki
				if (tabAdded) {
					scheduleWrapper.setWidget(new AcademicTitlesList());
				}
			}
		});
		
		add(listBuildingsHTMLLink);
		listBuildingsHTMLLink.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
				String tabLabel = "Buildings";
				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "BUILDINGS");
				
				//sciagamy dane do nowootwartej zakladki
				if (tabAdded) {
					scheduleWrapper.setWidget(new BuildingsList());
				}
			}
		});
		
		add(listPreferenceTypesHTMLLink);
		listPreferenceTypesHTMLLink.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
				String tabLabel = "Preference Types";
				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "PREFERENCE_TYPES");
				
				//sciagamy dane do nowootwartej zakladki
				if (tabAdded) {
					scheduleWrapper.setWidget(new PreferenceTypesList());
				}
			}
		});
		

		add(listRoomTypesHTMLLink);
		listRoomTypesHTMLLink.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
				String tabLabel = "Room types";
				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "ROOM_TYPES");
				
				//sciagamy dane do nowootwartej zakladki
				if (tabAdded) {
					scheduleWrapper.setWidget(new RoomTypesList());
				}
			}
		});

		add(listSubjectTypesHTMLLink);
		listSubjectTypesHTMLLink.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
				String tabLabel = "Subject types";
				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "SUBJECT_TYPES");
				
				//sciagamy dane do nowootwartej zakladki
				if (tabAdded) {
					scheduleWrapper.setWidget(new SubjectTypesList());
				}
			}
		});
		
		add(listSubgroupTypesHTMLLink);
		listSubgroupTypesHTMLLink.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
				String tabLabel = "Subgroup types";
				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "SUBGROUP_TYPES");
				
				//sciagamy dane do nowootwartej zakladki
				if (tabAdded) {
					scheduleWrapper.setWidget(new SubgroupTypesList());
				}
			}
		});
		
//		add(listStudiesTypesHTMLLink);
//		listStudiesTypesHTMLLink.addClickListener(new ClickListener() {
//			public void onClick(Widget sender) {
//				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
//				String tabLabel = "Studies types";
//				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "STUDIES_TYPES");
//				
//				//sciagamy dane do nowootwartej zakladki
//				if (tabAdded) {
//					scheduleWrapper.setWidget(new StudiesTypesList());
//				}
//			}
//		});

//		add(listSemesterTypesHTMLLink);
//		listSemesterTypesHTMLLink.addClickListener(new ClickListener() {
//			public void onClick(Widget sender) {
//				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
//				String tabLabel = "Semester types";
//				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "SEMESTER_TYPES");
//				
//				//sciagamy dane do nowootwartej zakladki
//				if (tabAdded) {
//					scheduleWrapper.setWidget(new SemesterTypesList());
//				}
//			}
//		});
		
		
		add(listYearGroupNamesHTMLLink);
		listYearGroupNamesHTMLLink.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				
				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
				String tabLabel = "Year group names";
				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "YEAR_GROUP_NAMES");
								
				//sciagamy dane do nowootwartej zakladki
				if (tabAdded) {
					scheduleWrapper.setWidget(new YearGroupNamesList());
				}
			}
		});
		
		
		
		
		add(new HTMLLink("<br />"));
		add(listSubjectNamesHTMLLink);
		listSubjectNamesHTMLLink.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				
				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
				String tabLabel = "Subject names";
				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "SUBJECT_NAMES");
				
				
				//sciagamy dane do nowootwartej zakladki
				if (tabAdded) {
					scheduleWrapper.setWidget(new SubjectNamesList());
				}
			}
		});
		
		add(listSubjectsHTMLLink);
		listSubjectsHTMLLink.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
				String tabLabel = "Subjects";
				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "SUBJECTS");
				
				//sciagamy dane do nowootwartej zakladki
				if (tabAdded) {
					scheduleWrapper.setWidget(new SubjectsList());
				}
			}
		});
		
		
		
		
		
		add(new HTMLLink("<br />"));		
		add(listLecturersHTMLLink);
		listLecturersHTMLLink.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
				String tabLabel = "Lecturers";
				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "LECTURERS");
				
				if (tabAdded) {
					scheduleWrapper.setWidget(new LecturersList());
				}
				
			}
		});
		
		add(listRoomsHTMLLink);
		listRoomsHTMLLink.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
				String tabLabel = "Rooms";
				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "ROOMS");
				
				//sciagamy dane do nowootwartej zakladki
				if (tabAdded) {
					scheduleWrapper.setWidget(new RoomsList());
				}
			}
		});



		
		add(listCalendarDaysHTMLLink);
		listCalendarDaysHTMLLink.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
				String tabLabel = "Calendar days";
				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "CALENDAR_DAYS");
				
				if (tabAdded) {
					scheduleWrapper.setWidget(new CalendarDaysList());
				}
			}
		});
		
		add(listSemestersYearGroupsHTMLLink);
		listSemestersYearGroupsHTMLLink.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				
				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
				String tabLabel = "Semester Year Groups";
				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "SEMESTER_YEAR_GROUPS");
				
				//sciagamy dane do nowootwartej zakladki
				if (tabAdded) {
					scheduleWrapper.setWidget(new SemestersYearGroupsList());
				}
				
			}
		});

		add(listGroupsHTMLLink);
		listGroupsHTMLLink.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				
				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
				String tabLabel = "Groups";
				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "GROUPS");
				
				//sciagamy dane do nowootwartej zakladki
				if (tabAdded) {
					scheduleWrapper.setWidget(new GroupsList());
				}
				
			}
		});
		
//		add(listSubgroupsHTMLLink);
//		listSubgroupsHTMLLink.addClickListener(new ClickListener() {
//			public void onClick(Widget sender) {
////				Planner.getMainHSP().setRightWidget(new LecturersList());
//				
//				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
//				String tabLabel = "Subgroups";
//				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "SUBGROUPS"); 
//
//				//sciagamy dane do nowootwartej zakladki
//				if (tabAdded) {
//					long groupID = -1;
//					scheduleWrapper.setWidget(new SubgroupsList(groupID));
//				}
//			}
//		});

		

		
//		add(listSemestersHTMLLink);
//		listSemestersHTMLLink.addClickListener(new ClickListener() {
//			public void onClick(Widget sender) {
//				Planner.getMainHSP().setRightWidget(new SemestersList());
//			}
//		});
		
		

		

		
//		add(listSubjectEventsHTMLLink);
//		listSubjectEventsHTMLLink.addClickListener(new ClickListener() {
//			public void onClick(Widget sender) {
//				MinimizableSimplePanel scheduleWrapper = new MinimizableSimplePanel();
//				String tabLabel = "Subject events";
//				boolean tabAdded = Planner.getTabPanel().add(scheduleWrapper, "" + tabLabel, "SUBJECT_EVENTS"); 
//
//				//sciagamy dane do nowootwartej zakladki
//				if (tabAdded) {
//					Schedule sched = null;
//					scheduleWrapper.setWidget(new SubjectEventsList(sched));
//				}
//			}
//		});
		
//		add(new CoolWidget());
	}
}